package com.cskaoyan.mall.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cskaoyan.mall.product.converter.dto.CategoryConverter;
import com.cskaoyan.mall.product.dto.*;
import com.cskaoyan.mall.product.mapper.CategoryTrademarkMapper;
import com.cskaoyan.mall.product.mapper.FirstLevelCategoryMapper;
import com.cskaoyan.mall.product.mapper.SecondLevelCategoryMapper;
import com.cskaoyan.mall.product.mapper.ThirdLevelCategoryMapper;
import com.cskaoyan.mall.product.model.FirstLevelCategory;
import com.cskaoyan.mall.product.model.SecondLevelCategory;
import com.cskaoyan.mall.product.model.ThirdLevelCategory;
import com.cskaoyan.mall.product.query.CategoryTrademarkParam;
import com.cskaoyan.mall.product.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
@Service
public class CategoryServiceImpl implements CategoryService {
    @Autowired
    CategoryConverter categoryConverter;
    @Autowired
    private FirstLevelCategoryMapper firstLevelCategoryMapper;
    @Autowired
    private SecondLevelCategoryMapper secondLevelCategoryMapper;
    @Autowired
    private ThirdLevelCategoryMapper thirdLevelCategoryMapper;

    @Override
    public List<FirstLevelCategoryDTO> getFirstLevelCategory() {
        QueryWrapper<FirstLevelCategoryDTO> queryWrapper=new QueryWrapper<>();
        List<FirstLevelCategory> firstLevelCategoryList=firstLevelCategoryMapper.selectList(null);
        List<FirstLevelCategoryDTO> firstLevelCategoryDTOList=categoryConverter.firstLevelCategoryPOs2DTOs(firstLevelCategoryList);
        return firstLevelCategoryDTOList;
    }

    @Override
    public List<SecondLevelCategoryDTO> getSecondLevelCategory(Long firstLevelCategoryId) {
        QueryWrapper<SecondLevelCategory> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("first_level_category_id", firstLevelCategoryId);
        List<SecondLevelCategory> secondLevelCategoryList=secondLevelCategoryMapper.selectList(queryWrapper);
        List<SecondLevelCategoryDTO> secondLevelCategoryDTOList=categoryConverter.secondLevelCategoryPOs2DTOs(secondLevelCategoryList);
        return secondLevelCategoryDTOList;
    }

    @Override
    public List<ThirdLevelCategoryDTO> getThirdLevelCategory(Long secondLevelCategoryId) {
        QueryWrapper<ThirdLevelCategory> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("second_level_category_id", secondLevelCategoryId);
        List<ThirdLevelCategory> thirdLevelCategoryList=thirdLevelCategoryMapper.selectList(queryWrapper);
        List<ThirdLevelCategoryDTO> thirdLevelCategoryDTOList=categoryConverter.thirdLevelCategoryPOs2DTOs(thirdLevelCategoryList);
        return thirdLevelCategoryDTOList;
    }

    @Override
    public List<TrademarkDTO> findTrademarkList(Long category3Id) {
        return List.of();
    }

    @Override
    public void save(CategoryTrademarkParam categoryTrademarkParam) {

    }

    @Override
    public List<TrademarkDTO> findUnLinkedTrademarkList(Long thirdLevelCategoryId) {
        return List.of();
    }

    @Override
    public void remove(Long thirdLevelCategoryId, Long trademarkId) {

    }

    @Override
    public CategoryHierarchyDTO getCategoryViewByCategoryId(Long thirdLevelCategoryId) {
        return null;
    }

    @Override
    public List<FirstLevelCategoryNodeDTO> getCategoryTreeList() {
        return List.of();
    }
}
